/**
 * This is a generated class and is not intended for modification.  To customize behavior
 * of this value object you may modify the generated sub-class of this class - VoFilteredClient.as.
 */

package com.model.valueObjects
{
import com.adobe.fiber.services.IFiberManagingService;
import com.adobe.fiber.util.FiberUtils;
import com.adobe.fiber.valueobjects.IValueObject;
import flash.events.Event;
import flash.events.EventDispatcher;
import mx.binding.utils.ChangeWatcher;
import mx.events.PropertyChangeEvent;
import mx.validators.ValidationResult;

import flash.net.registerClassAlias;
import flash.net.getClassByAlias;
import com.adobe.fiber.core.model_internal;
import com.adobe.fiber.valueobjects.IPropertyIterator;
import com.adobe.fiber.valueobjects.AvailablePropertyIterator;

use namespace model_internal;

[ExcludeClass]
public class _Super_VoFilteredClient extends flash.events.EventDispatcher implements com.adobe.fiber.valueobjects.IValueObject
{
    model_internal static function initRemoteClassAliasSingle(cz:Class) : void
    {
        try
        {
            if (flash.net.getClassByAlias("VoFilteredClient") == null)
            {
                flash.net.registerClassAlias("VoFilteredClient", cz);
            }
        }
        catch (e:Error)
        {
            flash.net.registerClassAlias("VoFilteredClient", cz);
        }
    }

    model_internal static function initRemoteClassAliasAllRelated() : void
    {
    }

    model_internal var _dminternal_model : _VoFilteredClientEntityMetadata;

    /**
     * properties
     */
    private var _internal_client_contact_phone : String;
    private var _internal_hilight : int;
    private var _internal_client_contact_email : String;
    private var _internal_client_contact_person : String;
    private var _internal_isSelected : Boolean;
    private var _internal_client_email : String;
    private var _internal_serialnumber : int;
    private var _internal_client_name : String;

    private static var emptyArray:Array = new Array();


    /**
     * derived property cache initialization
     */
    model_internal var _cacheInitialized_isValid:Boolean = false;

    model_internal var _changeWatcherArray:Array = new Array();

    public function _Super_VoFilteredClient()
    {
        _model = new _VoFilteredClientEntityMetadata(this);

        // Bind to own data properties for cache invalidation triggering
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "client_contact_phone", model_internal::setterListenerClient_contact_phone));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "client_contact_email", model_internal::setterListenerClient_contact_email));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "client_contact_person", model_internal::setterListenerClient_contact_person));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "client_email", model_internal::setterListenerClient_email));
        model_internal::_changeWatcherArray.push(mx.binding.utils.ChangeWatcher.watch(this, "client_name", model_internal::setterListenerClient_name));

    }

    /**
     * data property getters
     */

    [Bindable(event="propertyChange")]
    public function get client_contact_phone() : String
    {
        return _internal_client_contact_phone;
    }

    [Bindable(event="propertyChange")]
    public function get hilight() : int
    {
        return _internal_hilight;
    }

    [Bindable(event="propertyChange")]
    public function get client_contact_email() : String
    {
        return _internal_client_contact_email;
    }

    [Bindable(event="propertyChange")]
    public function get client_contact_person() : String
    {
        return _internal_client_contact_person;
    }

    [Bindable(event="propertyChange")]
    public function get isSelected() : Boolean
    {
        return _internal_isSelected;
    }

    [Bindable(event="propertyChange")]
    public function get client_email() : String
    {
        return _internal_client_email;
    }

    [Bindable(event="propertyChange")]
    public function get serialnumber() : int
    {
        return _internal_serialnumber;
    }

    [Bindable(event="propertyChange")]
    public function get client_name() : String
    {
        return _internal_client_name;
    }

    /**
     * data property setters
     */

    public function set client_contact_phone(value:String) : void
    {
        var oldValue:String = _internal_client_contact_phone;
        if (oldValue !== value)
        {
            _internal_client_contact_phone = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "client_contact_phone", oldValue, _internal_client_contact_phone));
        }
    }

    public function set hilight(value:int) : void
    {
        var oldValue:int = _internal_hilight;
        if (oldValue !== value)
        {
            _internal_hilight = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "hilight", oldValue, _internal_hilight));
        }
    }

    public function set client_contact_email(value:String) : void
    {
        var oldValue:String = _internal_client_contact_email;
        if (oldValue !== value)
        {
            _internal_client_contact_email = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "client_contact_email", oldValue, _internal_client_contact_email));
        }
    }

    public function set client_contact_person(value:String) : void
    {
        var oldValue:String = _internal_client_contact_person;
        if (oldValue !== value)
        {
            _internal_client_contact_person = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "client_contact_person", oldValue, _internal_client_contact_person));
        }
    }

    public function set isSelected(value:Boolean) : void
    {
        var oldValue:Boolean = _internal_isSelected;
        if (oldValue !== value)
        {
            _internal_isSelected = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "isSelected", oldValue, _internal_isSelected));
        }
    }

    public function set client_email(value:String) : void
    {
        var oldValue:String = _internal_client_email;
        if (oldValue !== value)
        {
            _internal_client_email = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "client_email", oldValue, _internal_client_email));
        }
    }

    public function set serialnumber(value:int) : void
    {
        var oldValue:int = _internal_serialnumber;
        if (oldValue !== value)
        {
            _internal_serialnumber = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "serialnumber", oldValue, _internal_serialnumber));
        }
    }

    public function set client_name(value:String) : void
    {
        var oldValue:String = _internal_client_name;
        if (oldValue !== value)
        {
            _internal_client_name = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "client_name", oldValue, _internal_client_name));
        }
    }

    /**
     * Data property setter listeners
     *
     * Each data property whose value affects other properties or the validity of the entity
     * needs to invalidate all previously calculated artifacts. These include:
     *  - any derived properties or constraints that reference the given data property.
     *  - any availability guards (variant expressions) that reference the given data property.
     *  - any style validations, message tokens or guards that reference the given data property.
     *  - the validity of the property (and the containing entity) if the given data property has a length restriction.
     *  - the validity of the property (and the containing entity) if the given data property is required.
     */

    model_internal function setterListenerClient_contact_phone(value:flash.events.Event):void
    {
        _model.invalidateDependentOnClient_contact_phone();
    }

    model_internal function setterListenerClient_contact_email(value:flash.events.Event):void
    {
        _model.invalidateDependentOnClient_contact_email();
    }

    model_internal function setterListenerClient_contact_person(value:flash.events.Event):void
    {
        _model.invalidateDependentOnClient_contact_person();
    }

    model_internal function setterListenerClient_email(value:flash.events.Event):void
    {
        _model.invalidateDependentOnClient_email();
    }

    model_internal function setterListenerClient_name(value:flash.events.Event):void
    {
        _model.invalidateDependentOnClient_name();
    }


    /**
     * valid related derived properties
     */
    model_internal var _isValid : Boolean;
    model_internal var _invalidConstraints:Array = new Array();
    model_internal var _validationFailureMessages:Array = new Array();

    /**
     * derived property calculators
     */

    /**
     * isValid calculator
     */
    model_internal function calculateIsValid():Boolean
    {
        var violatedConsts:Array = new Array();
        var validationFailureMessages:Array = new Array();

        var propertyValidity:Boolean = true;
        if (!_model.client_contact_phoneIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_client_contact_phoneValidationFailureMessages);
        }
        if (!_model.client_contact_emailIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_client_contact_emailValidationFailureMessages);
        }
        if (!_model.client_contact_personIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_client_contact_personValidationFailureMessages);
        }
        if (!_model.client_emailIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_client_emailValidationFailureMessages);
        }
        if (!_model.client_nameIsValid)
        {
            propertyValidity = false;
            com.adobe.fiber.util.FiberUtils.arrayAdd(validationFailureMessages, _model.model_internal::_client_nameValidationFailureMessages);
        }

        model_internal::_cacheInitialized_isValid = true;
        model_internal::invalidConstraints_der = violatedConsts;
        model_internal::validationFailureMessages_der = validationFailureMessages;
        return violatedConsts.length == 0 && propertyValidity;
    }

    /**
     * derived property setters
     */

    model_internal function set isValid_der(value:Boolean) : void
    {
        var oldValue:Boolean = model_internal::_isValid;
        if (oldValue !== value)
        {
            model_internal::_isValid = value;
            _model.model_internal::fireChangeEvent("isValid", oldValue, model_internal::_isValid);
        }
    }

    /**
     * derived property getters
     */

    [Transient]
    [Bindable(event="propertyChange")]
    public function get _model() : _VoFilteredClientEntityMetadata
    {
        return model_internal::_dminternal_model;
    }

    public function set _model(value : _VoFilteredClientEntityMetadata) : void
    {
        var oldValue : _VoFilteredClientEntityMetadata = model_internal::_dminternal_model;
        if (oldValue !== value)
        {
            model_internal::_dminternal_model = value;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "_model", oldValue, model_internal::_dminternal_model));
        }
    }

    /**
     * methods
     */


    /**
     *  services
     */
    private var _managingService:com.adobe.fiber.services.IFiberManagingService;

    public function set managingService(managingService:com.adobe.fiber.services.IFiberManagingService):void
    {
        _managingService = managingService;
    }

    model_internal function set invalidConstraints_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_invalidConstraints;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_invalidConstraints = value;
            _model.model_internal::fireChangeEvent("invalidConstraints", oldValue, model_internal::_invalidConstraints);
        }
    }

    model_internal function set validationFailureMessages_der(value:Array) : void
    {
        var oldValue:Array = model_internal::_validationFailureMessages;
        // avoid firing the event when old and new value are different empty arrays
        if (oldValue !== value && (oldValue.length > 0 || value.length > 0))
        {
            model_internal::_validationFailureMessages = value;
            _model.model_internal::fireChangeEvent("validationFailureMessages", oldValue, model_internal::_validationFailureMessages);
        }
    }

    model_internal var _doValidationCacheOfClient_contact_phone : Array = null;
    model_internal var _doValidationLastValOfClient_contact_phone : String;

    model_internal function _doValidationForClient_contact_phone(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfClient_contact_phone != null && model_internal::_doValidationLastValOfClient_contact_phone == value)
           return model_internal::_doValidationCacheOfClient_contact_phone ;

        _model.model_internal::_client_contact_phoneIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isClient_contact_phoneAvailable && _internal_client_contact_phone == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "client_contact_phone is required"));
        }

        model_internal::_doValidationCacheOfClient_contact_phone = validationFailures;
        model_internal::_doValidationLastValOfClient_contact_phone = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfClient_contact_email : Array = null;
    model_internal var _doValidationLastValOfClient_contact_email : String;

    model_internal function _doValidationForClient_contact_email(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfClient_contact_email != null && model_internal::_doValidationLastValOfClient_contact_email == value)
           return model_internal::_doValidationCacheOfClient_contact_email ;

        _model.model_internal::_client_contact_emailIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isClient_contact_emailAvailable && _internal_client_contact_email == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "client_contact_email is required"));
        }

        model_internal::_doValidationCacheOfClient_contact_email = validationFailures;
        model_internal::_doValidationLastValOfClient_contact_email = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfClient_contact_person : Array = null;
    model_internal var _doValidationLastValOfClient_contact_person : String;

    model_internal function _doValidationForClient_contact_person(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfClient_contact_person != null && model_internal::_doValidationLastValOfClient_contact_person == value)
           return model_internal::_doValidationCacheOfClient_contact_person ;

        _model.model_internal::_client_contact_personIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isClient_contact_personAvailable && _internal_client_contact_person == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "client_contact_person is required"));
        }

        model_internal::_doValidationCacheOfClient_contact_person = validationFailures;
        model_internal::_doValidationLastValOfClient_contact_person = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfClient_email : Array = null;
    model_internal var _doValidationLastValOfClient_email : String;

    model_internal function _doValidationForClient_email(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfClient_email != null && model_internal::_doValidationLastValOfClient_email == value)
           return model_internal::_doValidationCacheOfClient_email ;

        _model.model_internal::_client_emailIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isClient_emailAvailable && _internal_client_email == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "client_email is required"));
        }

        model_internal::_doValidationCacheOfClient_email = validationFailures;
        model_internal::_doValidationLastValOfClient_email = value;

        return validationFailures;
    }
    
    model_internal var _doValidationCacheOfClient_name : Array = null;
    model_internal var _doValidationLastValOfClient_name : String;

    model_internal function _doValidationForClient_name(valueIn:Object):Array
    {
        var value : String = valueIn as String;

        if (model_internal::_doValidationCacheOfClient_name != null && model_internal::_doValidationLastValOfClient_name == value)
           return model_internal::_doValidationCacheOfClient_name ;

        _model.model_internal::_client_nameIsValidCacheInitialized = true;
        var validationFailures:Array = new Array();
        var errorMessage:String;
        var failure:Boolean;

        var valRes:ValidationResult;
        if (_model.isClient_nameAvailable && _internal_client_name == null)
        {
            validationFailures.push(new ValidationResult(true, "", "", "client_name is required"));
        }

        model_internal::_doValidationCacheOfClient_name = validationFailures;
        model_internal::_doValidationLastValOfClient_name = value;

        return validationFailures;
    }
    

}

}
